{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 题库处理见math.py及math_functions.py\n",
    "# 股票分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name: tushare\n",
      "Version: 1.4.14\n",
      "Summary: A utility for crawling historical and Real-time Quotes data of China stocks\n",
      "Home-page: https://tushare.pro\n",
      "Author: Jimmy Liu\n",
      "Author-email: waditu@163.com\n",
      "License: BSD\n",
      "Location: c:\\Users\\1\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\n",
      "Requires: bs4, lxml, pandas, requests, simplejson, tqdm, websocket-client\n",
      "Required-by: \n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "%pip show tushare"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<>:2: SyntaxWarning: invalid escape sequence '\\P'\n",
      "<>:2: SyntaxWarning: invalid escape sequence '\\P'\n",
      "C:\\Users\\1\\AppData\\Local\\Temp\\ipykernel_40224\\2862113573.py:2: SyntaxWarning: invalid escape sequence '\\P'\n",
      "  sys.path.append(\"C:\\Program Files\\Python310\\Lib\\site-packages\")\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        ts_code trade_date   open   high    low  close  pre_close  change  \\\n",
      "0     920128.BJ   20241227  30.05  30.58  30.05  30.20      30.29   -0.09   \n",
      "1     920118.BJ   20241227  25.07  25.47  24.89  25.10      24.97    0.13   \n",
      "2     920111.BJ   20241227  24.41  26.34  24.21  25.25      24.89    0.36   \n",
      "3     920106.BJ   20241227  55.00  56.38  54.50  55.30      54.93    0.37   \n",
      "4     920099.BJ   20241227  28.80  29.48  28.62  29.19      28.99    0.20   \n",
      "...         ...        ...    ...    ...    ...    ...        ...     ...   \n",
      "5995  688228.SH   20241226  47.36  50.00  47.17  49.06      47.40    1.66   \n",
      "5996  688227.SH   20241226  26.22  26.83  25.97  26.61      26.61    0.00   \n",
      "5997  688226.SH   20241226  26.10  28.10  25.87  27.09      26.10    0.99   \n",
      "5998  688225.SH   20241226  20.87  21.00  19.98  20.22      20.70   -0.48   \n",
      "5999  688223.SH   20241226   7.75   7.78   7.59   7.60       7.78   -0.18   \n",
      "\n",
      "      pct_chg        vol      amount  \n",
      "0     -0.2971   10257.21   31075.550  \n",
      "1      0.5206    3818.53    9589.052  \n",
      "2      1.4464   42608.32  109087.672  \n",
      "3      0.6736    9552.36   52644.579  \n",
      "4      0.6899    8134.65   23730.639  \n",
      "...       ...        ...         ...  \n",
      "5995   3.5021   24305.81  118842.012  \n",
      "5996   0.0000   16586.83   43818.776  \n",
      "5997   3.7931   46123.04  126158.202  \n",
      "5998  -2.3188   23479.77   47896.192  \n",
      "5999  -2.3136  390061.07  298853.828  \n",
      "\n",
      "[6000 rows x 11 columns]\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "sys.path.append(\"C:\\Program Files\\Python310\\Lib\\site-packages\")\n",
    "import tushare as ts\n",
    "\n",
    "\n",
    "ts.set_token('128ce7f6b4e27a7ce2207e97d7570d8554cbe270f2ee452f2901a281')\n",
    "pro = ts.pro_api()\n",
    "\n",
    "params = {\n",
    "    \"ts_code\": \"601939.SH\",\n",
    "    \"trade_date\": \"\",\n",
    "    \"start_date\": 20100101,\n",
    "    \"end_date\": 20241225,\n",
    "    \"offset\": \"\",\n",
    "    \"limit\": \"\",\n",
    "    \"fields\": [\n",
    "        \"ts_code\",\n",
    "        \"trade_date\",\n",
    "        \"open\",\n",
    "        \"high\",\n",
    "        \"low\",\n",
    "        \"close\",\n",
    "        \"pre_close\",\n",
    "        \"change\",\n",
    "        \"pct_close\",\n",
    "        \"change\",\n",
    "        \"pct_chg\",\n",
    "        \"vol\",\n",
    "        \"amount\"\n",
    "    ]\n",
    "}\n",
    "df = pro.daily(params)\n",
    "print(df)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
